home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / XMSLB17.ARJ / XMSLIB.ASM < prev    next >
Assembly Source File  |  1991-09-02  |  25KB  |  547 lines

  1. %title "XMSLIB.ASM - Interface to the XMS driver for TurboC 2.0 and TC++ 1.0"
  2. %subttl "Copyright 1990, 1991 by Michael Graff"
  3.  
  4. ; $Id: xmslib.asm 1.7 91/09/02 12:18:03 explorer Exp Locker: explorer $
  5.  
  6. ; This package allows TurboC programs to use a XMS driver to store data
  7.  
  8. ; Version 1.2, 08-Mar-91
  9. ; Version 1.3, 07-May-91  Thanks to DTF
  10. ; Version 1.4, 26-May-91
  11. ; Version 1.5, 12-Jun-91  Fixed a few little errors
  12. ; Version 1.6, 02-Sep-91  Fixed a few documentation errors
  13.  
  14.  
  15.         ideal
  16.         model   MEMMOD                    ; tested: large, small, tiny, huge
  17.                                         ; Other TC models (other than possibly
  18.                                         ; HUGE) should work as well.
  19.  
  20. TRUE    equ     1
  21. FALSE   equ     0
  22.  
  23. XGetVersion     equ     00h             ; commands to the XMS driver
  24. XRequestHMA     equ     01h
  25. XReleaseHMA     equ     02h
  26. XGlobalE20      equ     03h
  27. XGlobalD20      equ     04h
  28. XLocalE20       equ     05h
  29. XLocalD20       equ     06h
  30. XQuery20        equ     07h
  31. XGetMemSize     equ     08h
  32. XAllocEMB       equ     09h
  33. XFreeEMB        equ     0ah
  34. XMoveEMB        equ     0bh
  35. XLockEMB        equ     0ch
  36. XUnlockEMB      equ     0dh
  37. XGetHandleInfo  equ     0eh
  38. XReallocEMB     equ     0fh
  39. XRequestUMB     equ     10h
  40. XReleaseUMB     equ     11h
  41.  
  42. ENone           equ     00h             ; "no error" error code
  43. ENotInitd       equ     01h             ; XMSSetup was never called before other XMS funcs
  44.  
  45. struc   ExtMemMoveStruct
  46.         TransferLength  dd      ?       ; 32-bit number of bytes to transfer
  47.         SourceHandle    dw      ?       ; Handle of source block
  48.         SourceOffset    dd      ?       ; 32-bit offset into source block
  49.         DestHandle      dw      ?       ; Handle of dest block
  50.         DestOffset      dd      ?       ; 32-bit offset into dest block
  51. ends    ExtMemMoveStruct
  52.  
  53.         codeseg
  54. _XMSDriver      dd      ?
  55. _XMSInitd       dw      FALSE
  56.  
  57. public  _XMS_Setup,_XMS_Version,_XMS_RequestHMA,_XMS_ReleaseHMA,_XMS_FreeMem
  58. public  _XMS_GlobalEnableA20,_XMS_GlobalDisableA20,_XMS_LocalEnableA20
  59. public  _XMS_LocalDisableA20,_XMS_QueryA20,_XMS_AllocEMB,_XMS_FreeEMB
  60. public  _XMS_MoveEMB,_XMS_LockEMB,_XMS_UnlockEMB,_XMS_GetEMBHandleInfo
  61. public  _XMS_ReallocEMB,_XMS_RequestUMB,_XMS_ReleaseUMB
  62.  
  63. ;--------------------------------------------------------------------------
  64. ; extern unsigned int far XMS_Setup(void);
  65. ;--------------------------------------------------------------------------
  66.  
  67. proc    _XMS_Setup       far
  68.         push    bp                      ; save TurboC's bp
  69.         mov     bp,sp                   ; use bp to address parameters
  70.         mov     [_XMSInitd],0           ; Routine has not init'd yet
  71.         mov     ax,4300h                ; XMS Driver installation check
  72.         int     2fh
  73.         cmp     al,80h                  ; returns 80h if installed
  74.         je short @@xmsfound
  75.         mov     ax,FALSE                ; XMS Driver not present
  76.         jmp     @@exit
  77. @@xmsfound:
  78.         mov     ax,4310h                ; get address of XMS driver
  79.         int     2fh
  80.         mov     [word _XMSDriver],bx    ; store offset
  81.         mov     [word _XMSDriver+2],es  ; store segment
  82.         inc     [_XMSInitd]             ; we have init'd our code
  83.         mov     ax,TRUE
  84. @@exit:
  85.         pop     bp                      ; restore TurboC's bp
  86.         ret                             ; we outa here
  87. endp    _XMS_Setup
  88.  
  89. ;-------------------------------------------------------------------------------
  90. ; extern unsigned char far XMS_Version(
  91. ;       unsigned int far *version, unsigned int far *internal,
  92. ;       unsigned int far *HMA);
  93. ;-------------------------------------------------------------------------------
  94.  
  95. proc    _XMS_Version     far
  96.         arg version:dword,internal:dword,HMA:dword
  97.  
  98.         push    bp                      ; save TurboC's bp
  99.         mov     bp,sp                   ; use bp to address parameters
  100.         cmp     [_XMSInitd],0           ; has XMSSetup been called?
  101.         jne     @@hasinitd              ; yes, continue
  102.         mov     al,ENotInitd            ; nope, return error code
  103.         jmp     short @@exit
  104. @@hasinitd:
  105.         mov     ah,XGetVersion          ; function to get version of HMA driver
  106.         call    [dword _XMSDriver]      ; call the XMS driver
  107.         les     di,[version]            ; point es:di to variable
  108.         mov     [word ptr es:di],ax
  109.         les     di,[internal]
  110.         mov     [word ptr es:di],bx
  111.         les     di,[HMA]
  112.         mov     [word ptr es:di],dx
  113.         mov     al,ENone                ; no error can occur here (?)
  114. @@exit:
  115.         pop     bp                      ; restore TurboC's bp
  116.         ret                             ; we outa here
  117. endp    _XMS_Version
  118.  
  119. ;-------------------------------------------------------------------------------
  120. ; extern unsigned char far XMS_RequestHMA(unsigned int mysize);
  121. ;-------------------------------------------------------------------------------
  122.  
  123. proc    _XMS_RequestHMA  far
  124.         arg mysize:word
  125.  
  126.         push    bp                      ; save TurboC's bp
  127.         mov     bp,sp                   ; use bp to address parameters
  128.         cmp     [_XMSInitd],0           ; has XMSSetup been called?
  129.         jne     @@hasinitd              ; yes, continue
  130.         mov     al,ENotInitd            ; nope, return error code
  131.         jmp     short @@exit
  132. @@hasinitd:
  133.         mov     dx,[mysize]             ; ammount of HMA wanted
  134.         mov     ah,XRequestHMA          ; function to allocate HMA
  135.         call    [dword _XMSDriver]      ; call the XMS driver
  136.         mov     al,bl                   ; return any error codes generated
  137. @@exit:
  138.         pop     bp                      ; restore TurboC's bp
  139.         ret                             ; we outa here
  140. endp    _XMS_RequestHMA
  141.  
  142. ;-------------------------------------------------------------------------------
  143. ; extern unsigned char far XMS_ReleaseHMA(void);
  144. ;-------------------------------------------------------------------------------
  145.  
  146. proc    _XMS_ReleaseHMA far
  147.  
  148.         push    bp                      ; save TurboC's bp
  149.         mov     bp,sp                   ; use bp to address parameters
  150.         cmp     [_XMSInitd],0           ; has XMSSetup been called?
  151.         jne     @@hasinitd              ; yes, continue
  152.         mov     al,ENotInitd            ; nope, return error code
  153.         jmp     short @@exit
  154. @@hasinitd:
  155.         mov     ah,XReleaseHMA          ; function to release HMA
  156.         call    [dword _XMSDriver]      ; call the XMS driver
  157.         mov     al,bl                   ; return any error codes generated
  158. @@exit:
  159.         pop     bp                      ; restore TurboC's bp
  160.         ret                             ; we outa here
  161. endp    _XMS_ReleaseHMA
  162.  
  163. ;-------------------------------------------------------------------------------
  164. ; extern unsigned char far XMS_GlobalEnableA20(void);
  165. ;-------------------------------------------------------------------------------
  166.  
  167. proc    _XMS_GlobalEnableA20    far
  168.  
  169.         push    bp                      ; save TurboC's bp
  170.         mov     bp,sp                   ; use bp to address parameters
  171.         cmp     [_XMSInitd],0           ; has XMSSetup been called?
  172.         jne     @@hasinitd              ; yes, continue
  173.         mov     al,ENotInitd            ; nope, return error code
  174.         jmp     short @@exit
  175. @@hasinitd:
  176.         mov     ah,XGlobalE20           ; function code
  177.         call    [dword _XMSDriver]      ; call the XMS driver
  178.         mov     al,bl                   ; return any error codes generated
  179. @@exit:
  180.         pop     bp                      ; restore TurboC's bp
  181.         ret                             ; we outa here
  182. endp    _XMS_GlobalEnableA20
  183.  
  184. ;-------------------------------------------------------------------------------
  185. ; extern unsigned char far XMS_GlobalDisableA20(void);
  186. ;-------------------------------------------------------------------------------
  187.  
  188. proc    _XMS_GlobalDisableA20   far
  189.  
  190.         push    bp                      ; save TurboC's bp
  191.         mov     bp,sp                   ; use bp to address parameters
  192.         cmp     [_XMSInitd],0           ; has XMSSetup been called?
  193.         jne     @@hasinitd              ; yes, continue
  194.         mov     al,ENotInitd            ; nope, return error code
  195.         jmp     short @@exit
  196. @@hasinitd:
  197.         mov     ah,XGlobalD20           ; function code
  198.         call    [dword _XMSDriver]      ; call the XMS driver
  199.         mov     al,bl                   ; return any error codes generated
  200. @@exit:
  201.         pop     bp                      ; restore TurboC's bp
  202.         ret                             ; we outa here
  203. endp    _XMS_GlobalDisableA20
  204.  
  205. ;-------------------------------------------------------------------------------
  206. ; extern unsigned char far XMS_LocalEnableA20(void);
  207. ;-------------------------------------------------------------------------------
  208.  
  209. proc    _XMS_LocalEnableA20     far
  210.  
  211.         push    bp                      ; save TurboC's bp
  212.         mov     bp,sp                   ; use bp to address parameters
  213.         cmp     [_XMSInitd],0           ; has XMSSetup been called?
  214.         jne     @@hasinitd              ; yes, continue
  215.         mov     al,ENotInitd            ; nope, return error code
  216.         jmp     short @@exit
  217. @@hasinitd:
  218.         mov     ah,XLocalE20            ; function code
  219.         call    [dword _XMSDriver]      ; call the XMS driver
  220.         mov     al,bl                   ; return any error codes generated
  221. @@exit:
  222.         pop     bp                      ; restore TurboC's bp
  223.         ret                             ; we outa here
  224. endp    _XMS_LocalEnableA20
  225.  
  226. ;-------------------------------------------------------------------------------
  227. ; extern unsigned char far XMS_LocalDisableA20(void);
  228. ;-------------------------------------------------------------------------------
  229.  
  230. proc    _XMS_LocalDisableA20    far
  231.  
  232.         push    bp                      ; save TurboC's bp
  233.         mov     bp,sp                   ; use bp to address parameters
  234.         cmp     [_XMSInitd],0           ; has XMSSetup been called?
  235.         jne     @@hasinitd              ; yes, continue
  236.         mov     al,ENotInitd            ; nope, return error code
  237.         jmp     short @@exit
  238. @@hasinitd:
  239.         mov     ah,XLocalD20            ; function code
  240.         call    [dword _XMSDriver]      ; call the XMS driver
  241.         mov     al,bl                   ; return any error codes generated
  242. @@exit:
  243.         pop     bp                      ; restore TurboC's bp
  244.         ret                             ; we outa here
  245. endp    _XMS_LocalDisableA20
  246.  
  247. ;-------------------------------------------------------------------------------
  248. ; extern unsigned char far XMS_QueryA20(unsigned int far *state);
  249. ;-------------------------------------------------------------------------------
  250.  
  251. proc    _XMS_QueryA20   far
  252.         arg     state:dword
  253.         push    bp                      ; save TurboC's bp
  254.         mov     bp,sp                   ; use bp to address parameters
  255.         cmp     [_XMSInitd],0           ; has XMSSetup been called?
  256.         jne     @@hasinitd              ; yes, continue
  257.         mov     al,ENotInitd            ; nope, return error code
  258.         jmp     short @@exit
  259. @@hasinitd:
  260.         mov     ah,XQuery20             ; function code
  261.         call    [dword _XMSDriver]      ; call the XMS driver
  262.         les     di,[state]              ; point to return value
  263.         mov     [word ptr es:di],ax     ; return A20 state
  264.         mov     al,bl                   ; return any error codes generated
  265. @@exit:
  266.         pop     bp                      ; restore TurboC's bp
  267.         ret                             ; we outa here
  268. endp    _XMS_QueryA20
  269.  
  270. ;-------------------------------------------------------------------------------
  271. ; extern unsigned char far XMS_FreeMem(
  272. ;       unsigned int far *freemem, unsigned int far *totmem);
  273. ;-------------------------------------------------------------------------------
  274.  
  275. proc    _XMS_FreeMem     far
  276.         arg freemem:dword,totmem:dword
  277.  
  278.         push    bp                      ; save TurboC's bp
  279.         mov     bp,sp                   ; use bp to address parameters
  280.         cmp     [_XMSInitd],0           ; has XMSSetup been called?
  281.         jne     @@hasinitd              ; yes, continue
  282.         mov     al,ENotInitd            ; nope, return error code
  283.         jmp     short @@exit
  284. @@hasinitd:
  285.         mov     ah,XGetMemSize          ; function to get free/total memory
  286.         call    [dword _XMSDriver]      ; call the XMS driver
  287.         les     di,[freemem]            ; point es:di to freemem
  288.         mov     [word ptr es:di],ax
  289.         les     di,[totmem]
  290.         mov     [word ptr es:di],dx
  291.         mov     al,bl                   ; transfer XMS error code to al
  292. @@exit:
  293.         pop     bp                      ; restore TurboC's bp
  294.         ret                             ; we outa here
  295. endp    _XMS_FreeMem
  296.  
  297. ;-------------------------------------------------------------------------------
  298. ; extern unsigned char far XMS_AllocEMB(
  299. ;       unsigned int mysize, unsigned int far *handle);
  300. ;-------------------------------------------------------------------------------
  301.  
  302. proc    _XMS_AllocEMB   far
  303.         arg mysize:word,handle:dword
  304.  
  305.         push    bp                      ; save TurboC's bp
  306.         mov     bp,sp                   ; use bp to address parameters
  307.         cmp     [_XMSInitd],0           ; has XMSSetup been called?
  308.         jne     @@hasinitd              ; yes, continue
  309.         mov     al,ENotInitd            ; nope, return error code
  310.         jmp     short @@exit
  311. @@hasinitd:
  312.         mov     ah,XAllocEMB            ; function code
  313.         mov     dx,[mysize]             ; number of K to allocate
  314.         call    [dword _XMSDriver]      ; call the XMS driver
  315.         les     di,[handle]
  316.         mov     [word ptr es:di],dx     ; save handle number
  317.         mov     al,bl                   ; transfer XMS error code to al
  318. @@exit:
  319.         pop     bp                      ; restore TurboC's bp
  320.         ret                             ; we outa here
  321. endp    _XMS_AllocEMB
  322.  
  323. ;-------------------------------------------------------------------------------
  324. ; extern unsigned char far XMS_FreeEMB(unsigned int handle);
  325. ;-------------------------------------------------------------------------------
  326.  
  327. proc    _XMS_FreeEMB    far
  328.         arg     handle:word
  329.  
  330.         push    bp                      ; save TurboC's bp
  331.         mov     bp,sp                   ; use bp to address parameters
  332.         cmp     [_XMSInitd],0           ; has XMSSetup been called?
  333.         jne     @@hasinitd              ; yes, continue
  334.         mov     al,ENotInitd            ; nope, return error code
  335.         jmp     short @@exit
  336. @@hasinitd:
  337.         mov     ah,XFreeEMB             ; function code
  338.         mov     dx,[handle]             ; handle number to free
  339.         call    [dword _XMSDriver]      ; call the XMS driver
  340.         mov     al,bl                   ; transfer XMS error code to al
  341. @@exit:
  342.         pop     bp                      ; restore TurboC's bp
  343.         ret                             ; we outa here
  344. endp    _XMS_FreeEMB
  345.  
  346. ;-------------------------------------------------------------------------------
  347. ; extern unsigned char far XMS_MoveEMB(struct EMMMoveStruct far *MoveRec);
  348. ;-------------------------------------------------------------------------------
  349.  
  350. proc    _XMS_MoveEMB    far
  351.         arg     MoveRec:dword
  352.  
  353.         push    bp                      ; save TurboC's bp
  354.         mov     bp,sp                   ; use bp to address parameters
  355.         xor     bl,bl                   ; reset error code to 0
  356.         cmp     [_XMSInitd],0           ; has XMSSetup been called?
  357.         jne     @@hasinitd              ; yes, continue
  358.         mov     al,ENotInitd            ; nope, return error code
  359.         jmp     short @@exit
  360. @@hasinitd:
  361.         push    ds                      ; save Turbo's data segment
  362.         mov     ah,XMoveEMB             ; function code
  363.         lds     si,[MoveRec]            ; Point ds:si to MoveRec
  364.         call    [dword cs:_XMSDriver]   ; call the XMS driver
  365.         mov     al,bl                   ; transfer XMS error code to al
  366.         pop     ds                      ; restore Turbo's data segment
  367. @@exit:
  368.         pop     bp                      ; restore TurboC's bp
  369.         ret                             ; we outa here
  370. endp    _XMS_MoveEMB
  371.  
  372. ;-------------------------------------------------------------------------------
  373. ; extern unsigned char far XMS_LockEMB(unsigned int handle, void far *address);
  374. ;-------------------------------------------------------------------------------
  375.  
  376. proc    _XMS_LockEMB    far
  377.         arg     handle:word,address:dword
  378.  
  379.         push    bp                      ; save TurboC's bp
  380.         mov     bp,sp                   ; use bp to address parameters
  381.         cmp     [_XMSInitd],0           ; has XMSSetup been called?
  382.         jne     @@hasinitd              ; yes, continue
  383.         mov     al,ENotInitd            ; nope, return error code
  384.         jmp     short @@exit
  385. @@hasinitd:
  386.         mov     ah,XLockEMB             ; function code
  387.         mov     dx,[handle]             ; handle number to Lock
  388.         call    [dword _XMSDriver]      ; call the XMS driver
  389.         cmp     ax,1                    ; was the call successful?
  390.         je      @@success               ; yep, so jump!
  391.         mov     al,bl                   ; transfer XMS error code to al
  392.         jmp     short @@exit            ; get out
  393. @@success:
  394.         mov     al,0                    ; return no error code
  395.         les     di,[address]            ; point to address
  396.         mov     [word ptr es:di],bx     ; store the offset
  397.         mov     [word ptr es:di+2],dx   ; store the segment
  398. @@exit:
  399.         pop     bp                      ; restore TurboC's bp
  400.         ret                             ; we outa here
  401. endp    _XMS_LockEMB
  402.  
  403. ;-------------------------------------------------------------------------------
  404. ; extern unsigned char far XMS_UnlockEMB(unsigned int handle);
  405. ;-------------------------------------------------------------------------------
  406.  
  407. proc    _XMS_UnlockEMB  far
  408.         arg     handle:word
  409.  
  410.         push    bp                      ; save TurboC's bp
  411.         mov     bp,sp                   ; use bp to address parameters
  412.         cmp     [_XMSInitd],0           ; has XMSSetup been called?
  413.         jne     @@hasinitd              ; yes, continue
  414.         mov     al,ENotInitd            ; nope, return error code
  415.         jmp     short @@exit
  416. @@hasinitd:
  417.         mov     ah,XUnlockEMB           ; function code
  418.         mov     dx,[handle]             ; handle number to Unlock
  419.         call    [dword _XMSDriver]      ; call the XMS driver
  420.         mov     al,bl                   ; transfer XMS error code to al
  421. @@exit:
  422.         pop     bp                      ; restore TurboC's bp
  423.         ret                             ; we outa here
  424. endp    _XMS_UnlockEMB
  425.  
  426. ;-------------------------------------------------------------------------------
  427. ; extern unsigned char far XMS_GetEMBHandleInfoEMB(
  428. ;       unsigned int handle, unsigned char far *LockCount,
  429. ;       unsigned char far *EMBHandlesFree, unsigned int far *EMBlength);
  430. ;-------------------------------------------------------------------------------
  431.  
  432. proc    _XMS_GetEMBHandleInfo   far
  433.         arg     handle:word,LockCount:dword,EMBHandlesFree:dword,EMBlength:dword
  434.  
  435.         push    bp                      ; save TurboC's bp
  436.         mov     bp,sp                   ; use bp to address parameters
  437.         cmp     [_XMSInitd],0           ; has XMSSetup been called?
  438.         jne     @@hasinitd              ; yes, continue
  439.         mov     al,ENotInitd            ; nope, return error code
  440.         jmp     short @@exit
  441. @@hasinitd:
  442.         mov     ah,XGetHandleInfo       ; function code
  443.         mov     dx,[handle]             ; handle number to GetEMBHandleInfo
  444.         call    [dword _XMSDriver]      ; call the XMS driver
  445.         cmp     ax,1                    ; was the call successful?
  446.         je      @@success               ; yep, so jump!
  447.         mov     al,bl                   ; transfer XMS error code to al
  448.         jmp     short @@exit            ; get out
  449. @@success:
  450.         mov     al,0                    ; return no error code
  451.         les     di,[LockCount]          ; set up es:di as a pointer
  452.         mov     [byte ptr es:di],bh     ; save lock count
  453.         les     di,[EMBHandlesFree]
  454.         mov     [byte ptr es:di],bl     ; save # of free handles in system
  455.         les     di,[EMBlength]
  456.         mov     [word ptr es:di],dx     ; save block length
  457. @@exit:
  458.         pop     bp                      ; restore TurboC's bp
  459.         ret                             ; we outa here
  460. endp    _XMS_GetEMBHandleInfo
  461.  
  462. ;-------------------------------------------------------------------------------
  463. ; extern unsigned char far XMS_ReallocEMB(
  464. ;       unsigned int handle, unsigned int newsize);
  465. ;-------------------------------------------------------------------------------
  466.  
  467. proc    _XMS_ReallocEMB  far
  468.         arg     handle:word,newsize:word
  469.  
  470.         push    bp                      ; save TurboC's bp
  471.         mov     bp,sp                   ; use bp to address parameters
  472.         cmp     [_XMSInitd],0           ; has XMSSetup been called?
  473.         jne     @@hasinitd              ; yes, continue
  474.         mov     al,ENotInitd            ; nope, return error code
  475.         jmp     short @@exit
  476. @@hasinitd:
  477.         mov     ah,XReallocEMB          ; function code
  478.         mov     dx,[handle]             ; handle number to reallocate
  479.         mov     bx,[newsize]            ; new size wanted
  480.         call    [dword _XMSDriver]      ; call the XMS driver
  481.         mov     al,bl                   ; transfer XMS error code to al
  482. @@exit:
  483.         pop     bp                      ; restore TurboC's bp
  484.         ret                             ; we outa here
  485. endp    _XMS_ReallocEMB
  486.  
  487. ;-------------------------------------------------------------------------------
  488. ; extern unsigned char far XMS_RequestUMB(
  489. ;       unsigned int SizeWanted,
  490. ;       unsigned int far *segaddr,
  491. ;       unsigned int far *SizeUgot);
  492. ;-------------------------------------------------------------------------------
  493.  
  494. proc    _XMS_RequestUMB far
  495.         arg     sizewanted:word,segaddr:dword,SizeUgot:dword
  496.  
  497.         push    bp                      ; save TurboC's bp
  498.         mov     bp,sp                   ; use bp to address parameters
  499.         cmp     [_XMSInitd],0           ; has XMSSetup been called?
  500.         jne     @@hasinitd              ; yes, continue
  501.         mov     al,ENotInitd            ; nope, return error code
  502.         jmp     short @@exit
  503. @@hasinitd:
  504.         mov     ah,XRequestUMB          ; function code
  505.         mov     dx,[sizewanted]         ; nuumber of paragraphs we want
  506.         call    [dword _XMSDriver]      ; call the XMS driver
  507.         les     di,[SizeUgot]           ; we store a value here all the time
  508.         mov     [word ptr es:di],dx     ; either size requested or max free
  509.         cmp     ax,1                    ; was the call successful?
  510.         je      @@success               ; yep, so jump!
  511.         mov     al,bl                   ; transfer XMS error code to al
  512.         jmp     short @@exit            ; get out
  513. @@success:
  514.         mov     al,0                    ; return no error code
  515.         les     di,[segaddr]            ; point to address
  516.         mov     [word ptr es:di],bx     ; store the segment
  517. @@exit:
  518.         pop     bp                      ; restore TurboC's bp
  519.         ret                             ; we outa here
  520. endp    _XMS_RequestUMB
  521.  
  522. ;-------------------------------------------------------------------------------
  523. ; extern unsigned char far XMS_ReleaseUMB(unsigned int segaddr);
  524. ;-------------------------------------------------------------------------------
  525.  
  526. proc    _XMS_ReleaseUMB  far
  527.         arg     segaddr:word
  528.  
  529.         push    bp                      ; save TurboC's bp
  530.         mov     bp,sp                   ; use bp to address parameters
  531.         cmp     [_XMSInitd],0           ; has XMSSetup been called?
  532.         jne     @@hasinitd              ; yes, continue
  533.         mov     al,ENotInitd            ; nope, return error code
  534.         jmp     short @@exit
  535. @@hasinitd:
  536.         mov     ah,XReleaseUMB          ; function code
  537.         mov     dx,[segaddr]            ; handle number to Release
  538.         call    [dword _XMSDriver]      ; call the XMS driver
  539.         mov     al,bl                   ; transfer XMS error code to al
  540. @@exit:
  541.         pop     bp                      ; restore TurboC's bp
  542.         ret                             ; we outa here
  543. endp    _XMS_ReleaseUMB
  544.  
  545. ;------------- End of file! ---------------------------------------------------
  546.         end
  547.